package com.mes.web.controller.biz;

import com.github.pagehelper.PageInfo;
import com.mes.biz.domain.BizProduct;
import com.mes.biz.domain.BizPurchase;
import com.mes.biz.domain.BizPurchaseDetail;
import com.mes.biz.domain.BizSupplierPayable;
import com.mes.biz.service.BizProductService;
import com.mes.biz.service.BizPurchaseDetailService;
import com.mes.biz.service.BizPurchaseService;
import com.mes.biz.service.BizSupplierPayableService;
import com.mes.common.annotation.Log;
import com.mes.common.core.controller.BaseController;
import com.mes.common.core.domain.BaseEntity;
import com.mes.common.core.domain.R;
import com.mes.common.core.page.PageDomain;
import com.mes.common.enums.BusinessType;
import com.mes.framework.cache.DictUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 应付账款Controller
 * @author wy
 * @email wy
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/biz/bizSupplierPayable")
public class BizSupplierPayableController extends BaseController {

    @Autowired
    private BizSupplierPayableService bizSupplierPayableService;
    /**
     * 应付账款列表
     */
    @GetMapping("/list")
    public R<PageInfo> list(BizSupplierPayable bizSupplierPayable, HttpServletRequest request, HttpServletResponse response) {
        bizSupplierPayable.setPage(new PageDomain(request, response));
        return R.data(bizSupplierPayableService.findPage(bizSupplierPayable));
    }

    /**
     * 获取供应商应付账款信息
     */
    @GetMapping(value = "/{supplierCode}")
    public R<BizSupplierPayable> detail(@PathVariable("supplierCode") String supplierCode) {
        return R.data(bizSupplierPayableService.getBizSupplierPayableBySupplierCode(supplierCode));
    }
}
